package meituan1.problem3;

import java.util.*;

/**
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int inputNum = sc.nextInt();
        int queryNum = sc.nextInt();
        Map<Integer, int[]> recordMap = new HashMap<>();
        int totalInputNum = inputNum;
        while(inputNum -- > 0){
            int curNum = sc.nextInt();
            if(recordMap.containsKey(curNum)){
                int[] curRecord = recordMap.get(curNum);
                curRecord[1] = totalInputNum - inputNum;
            }else{
                int[] posiRecord = new int[2];
                Arrays.fill(posiRecord, totalInputNum - inputNum);
                recordMap.put(curNum, posiRecord);
            }
        }
        while (queryNum -- > 0){
            int curQuery = sc.nextInt();
            if(recordMap.containsKey(curQuery)){
                int[] queryRecord = recordMap.get(curQuery);
                System.out.print(queryRecord[0] + " ");
                System.out.println(queryRecord[1]);
            }else{
                System.out.println(0);
            }
        }
    }
}
